﻿@model IEnumerable<RedSand.Site.Models.ActionInfo>
<script type="text/javascript">
    $(function () {
        $("div#navigation ul li a, div#navigation ul li span")
	    .bind('click', function (event) {
	        if ($(this).next('ul').size() !== 0) {
	            $(this).next('ul').slideToggle('fast', function () {
	                $(this).toggleClass('closed');
	            });
	            event.preventDefault();
	        }
	    });
        $("div#navigation ul li a").click(function () {
            $("div#navigation ul li a.active").removeClass('active');
            $(this).addClass('active');
        });
        $("div#navigation ul li a[href*='" + location.pathname + "']").addClass('active');
    });
</script>
<div id="navigation">
    <ul>
        @foreach (var parent in Model.Where(item => item.ParentID == 0 && item.ShowOnMenu))
        {
            var sub = Model.Where(item => item.ParentID == parent.ActionID && item.ShowOnMenu);
            if (sub != null)
            {
                <li>
                    <a class="@parent.CssClass" href="#">@parent.Name</a>
                    <ul>
                        @foreach(var child in sub)
                        {
                            <li><a href="@child.Link">@child.Name</a></li>
                        }
                    </ul>
                </li>
            }
        }
    </ul>
</div>
